import { TemplateRef } from '@angular/core';
import { LvFilterMode } from '../core/types';
import { FilterItem, TableFilterConfig } from '../datatable/interface';

export interface PureTableFilterConfig {
  filterMode?: LvFilterMode; // 过滤类型
  /* 是否大小写敏感 */
  caseSensitive?: boolean;
  filterIcon?: string; // 过滤图标
  /* 根据全部数据自定义过滤 */
  customFilter?: <T>(data: T[] | null, filter: TableFilterConfig) => T[] | null;
  /* 根据单项数据自定义过滤 */
  customItemFilter?: <T>(data: T | null, filter: TableFilterConfig) => boolean;
}

export interface FilterDefaultConfig {
  /* 过滤列表是否支持过滤 */
  filterSearch?: boolean;
  /* 是否为多选过滤 */
  filterMultiple?: boolean;
  /* 是否显示全选按钮，配置 filterMultiple:true 时有效 */
  filterCheckAll?: boolean;
  /* 选中选项后立即执行过滤 */
  filterAuto?: boolean;
  /* 选项自定义模板 */
  filtersTemplate?: TemplateRef<any>;
}

export type TransferColumnItem = {
  [key: string]: any;
  key: string; // 键
  label: string;
  width?: string | number;
  align?: 'left' | 'center' | 'right';
  isHidden?: boolean; // 列是否隐藏
  disabled?: boolean;
  render?: TemplateRef<any>; // 单元格自定义模板
  filters?: FilterItem[];
  filterType?: FilterType | 'search' | 'default' | 'date'; // NEED_DO：适配原有写法，后续待删除
  sort?: boolean; // 排序
} & PureTableFilterConfig &
  FilterDefaultConfig;

export type TransferBelong = 'source' | 'target';

export interface SelectionFactor {
  belong: TransferBelong;
  selection: Array<{ [key: string]: any }> | { [key: string]: any };
}

// 表头过滤类型
export enum FilterType {
  DEFAULT = 1,
  SEARCH = 2,
  DATE = 3,
}

export type TransferModeType = 'copy' | 'cut';

export type ModeType = 'default' | 'simple';

export type TransferType = 'table' | 'checkbox' | 'tree';

export enum TransferModeTypeEnum {
  DEFAULT = 'default',
  SIMPLE = 'simple',
}

export enum TransferTypeEnum {
  TABLE = 'table',
  CHECKBOX = 'checkbox',
  TREE = 'tree',
}
